package com.csht.service.Impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.csht.mapper.CshtUserMapper;
import com.csht.model.CshtUser;
import com.csht.service.FindToService;
import com.csht.util.MD5;

/**
 * 修改用户名service
 * @author chenhuiyan
 *
 */
@Service
public class FindToServiceImpl implements FindToService {
	
	@Autowired
	private CshtUserMapper cshtUserMapper;

	/**
	 * 根据电话修改用户名
	 */
	@Override
	public void updateUsername(String userTel, String username) throws Exception {
		CshtUser cshtUser = new CshtUser();
		cshtUser.setUserTel(userTel);
		cshtUser.setUserUsername(username);
		cshtUserMapper.updateUsername(cshtUser);
	}

	/**
	 * 根据电话修改用户密码
	 */
	@Override
	public void updatePassword(String userTel, String userPassword) throws Exception {
		CshtUser cshtUser = new CshtUser();
		cshtUser.setUserTel(userTel);
		cshtUser.setUserPassword(MD5.getMD5Code(userPassword));
		cshtUserMapper.updatePassword(cshtUser);
	}

}
